#include "setwig.h"
#include "ui_setwig.h"
#include "mqtthandler.h"
#include <QDebug>
#include <globalval.h>
#include<QMessageBox>
#include <Qtime>
#include <QString>
#include <QHostAddress>
#include <QVariant>
#include <QByteArray>
#include <QUdpSocket>

SetWig::SetWig(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SetWig)
{
    ui->setupUi(this);

}

SetWig::~SetWig()
{
    delete ui;
}

void SetWig::on_moshi_Button_clicked()
{
    QMQTT::Message msg;
    msg.setTopic(TOPIC_CTL_DOWN);
    qDebug()<< ui->comboBox->currentText();
    if(( ui->comboBox->currentText())=="循环模式")
    {
        QByteArray payload = "{\"key\":2,\"name\":\"mode\",\"data\":1}";
        msg.setPayload(payload);
        GlobalVal::mqtt->publish(msg);

    }
    else if(( ui->comboBox->currentText())=="对比模式")
    {
        QByteArray payload = "{\"key\":2,\"name\":\"mode\",\"data\":2}";
        msg.setPayload(payload);
        GlobalVal::mqtt->publish(msg);
    }
    else if(( ui->comboBox->currentText())=="刷新模式")
    {
        QByteArray payload = "{\"key\":2,\"name\":\"mode\",\"data\":3}";
        msg.setPayload(payload);
        GlobalVal::mqtt->publish(msg);
    }
//    ui->comboBox->setEnabled(false);
//    ui->moshi_Button->setEnabled(false);


}
